global keepers1973 ""


/* Leftover generated variables from previous run that wrote to source */
drop yr id _merge

numlabel, add

genl yr=1973
global keepers1973 $keepers1973 yr

genl id=v1
global keepers1973 $keepers1973 id

merge 1:1 v1 using "$sourcedatadir/se/0040orig_ink.dta"

genl income=V203
genl income3=income
centile income, c(33 66 100)
replace income3=0 if income<=r(c_1)
centile income, c(33 66 100)
replace income3=1 if income>r(c_1) & income<=r(c_2)
centile income, c(33 66 100)
replace income3=2 if income>r(c_2) & income<=r(c_3)
global keepers1973 $keepers1973 income3

genl pid_ce=(v165==22 & v166==1)
replace pid_ce=. if v164==.
global keepers1973 $keepers1973 pid_ce

genl pid_gov=pid_ce
global keepers1973 $keepers1973 pid_gov

genl vote_ce=v180
recode vote_ce 22=1 .=. else=0
global keepers1973 $keepers1973 vote_ce

genl vote_gov=vote_ce
global keepers1973 $keepers1973 vote_gov


genl gpi=v12
recode gpi 8=2.5
replace gpi=abs(gpi-4)/3
global keepers1973 $keepers1973 gpi

genl socref=v138
recode socref 8=3
replace socref=abs(socref-5)/4
global keepers1973 $keepers1973 socref

genl degree=v219
recode degree 69 79=1 11/59=0
global keepers1973 $keepers1973 degree


// Class/occupation

gen class_resp_3cat = v211
recode class_resp_3cat 1/7=3 10/25=2 30/40=1
replace class_resp_3cat = . if class_resp_3cat > 40
label variable class_resp_3cat "Social class (3 cats.): higher value is higher class"
*label define LblClassGrade 1 "A: (Higher man.; prof." 2 "B: Lower man.; admin." 3 "C1A: Skilled; supervis. non-manu." 4 "C1B: Lower non-manu." 5 "C2: Skilled manu." 6 "D: Unskilled manu."
*label values class_head_grade LblClassGrade
global keepers1973 $keepers1973 class_resp_3cat

gen class_spou_3cat = v225
recode class_spou_3cat 1/7=3 10/25=2 30/40=1
replace class_spou_3cat = . if class_spou_3cat > 40
label variable class_spou_3cat "Social class (3 cats.): higher value is higher class"
*label define LblClassGrade 1 "A: (Higher man.; prof." 2 "B: Lower man.; admin." 3 "C1A: Skilled; supervis. non-manu." 4 "C1B: Lower non-manu." 5 "C2: Skilled manu." 6 "D: Unskilled manu."
*label values class_head_grade LblClassGrade
global keepers1973 $keepers1973 class_spou_3cat

gen male = v8
recode male 1=1 2=0
global keepers1973 $keepers1973 male

gen married = v9
recode married 1=1 2/5=0
global keepers1973 $keepers1973 married

gen unionmem_resp = v216
recode unionmem_resp 1/4=1 .=0
global keepers1973 $keepers1973 unionmem_resp

gen unionmem_spou = v230
recode unionmem_spou 1/4=1 .=0
global keepers1973 $keepers1973 unionmem_spou



// Pascal/SM moderators

    gen party_ID=. 
   replace party_ID=1 if v164==1 & v165==11
   replace party_ID=2 if v164==1 & v165==22
   replace party_ID=3 if v164==1 & v165==33
   replace party_ID=4 if v164==1 & v165==44
  
   replace party_ID=6 if v164==1 & v165==66
   replace party_ID=7 if v164==1 & v165==87

   replace party_ID=8 if v164==1 & v165==88
   
   replace party_ID=9 if v164==1 & v165==12
 
   replace party_ID=10 if v164==1 & v165==55
 
 replace party_ID=11 if v164==1 & v165==13
 replace party_ID=12 if v164==1 & v165==71
 replace party_ID=13 if v164==1 & v165==72
 lab def party_ID 1 "v‰nsterpartiet kom " 2 "socialdemokraterna" 3"centerpartiet" 4"folkpartiet" 5"hˆgerpartiet" 6"kristen demokratis" 7 "other" 8 "will not answer"9 " kommunistiska fˆrbundet marxist-len" 10 " moderata samlingspartiet " 11 "sveriges kommunis" 12 "borgerligt "  13 "FC+C" 14 "lokal borgerlig" 15 "skÂnepartiet" 16 "kommunistiska arbetarefˆrbundet" 17 "vpk, apk, kpmlr, skp, kaf" 18 "grˆnt parti" 19 "ny demokrati"
 lab val party_ID party_ID
  tab party_ID, m
 tab party_ID v165, m

    foreach var of varlist v135 v136 v137{
        gen Z`var'=`var'
		replace Z`var'=1 if `var'==5
		replace Z`var'=2 if `var'==4
		replace Z`var'=2.5 if `var'==8
		replace Z`var'=3 if `var'==2
		replace Z`var'=4 if `var'==1
		replace Z`var'=(Z`var'-1)/3
		tab Z`var' `var', m
  }

   rename Zv135 state_employment
  lab var state_employment "1=state intervention reduce unemployment risk"
  
    rename Zv136 no_state
  lab var no_state "1=enterprise perform better without state intervention"
  
    rename Zv137 econ_control
  lab var  econ_control "1=agree state control limit bank and industry influence"
  
  gen right=v172/100
  tab right
  lab var right "1=far right"

  
     gen talk_politic=.
 replace talk_politic=1 if v159==1
 replace talk_politic=0.5 if v159==3 | v159==8
 replace talk_politic=0 if v159==5
 tab v159 talk_politic, m
 
  lab var talk_politic "1=often talk politic outside and inside family" 
  
  gen newspaper_politics=.
 replace newspaper_politics=0 if v145==1
 replace newspaper_politics=0.33 if v145==2
 replace newspaper_politics=0.66 if v145==3
 replace newspaper_politics=1 if v145==4
  replace newspaper_politics=0.5 if v145==8

	
 
 tab v145 newspaper_politics, m
 lab var newspaper_politics "1=read more politic articles"

 
 
gen anti_econ_control=.
replace anti_econ_control=0.3333333 if econ_control>0.5 & econ_control<1
replace anti_econ_control=0.6666666 if econ_control>0 & econ_control<0.5
replace anti_econ_control=1 if econ_control==0
replace anti_econ_control=0.5 if econ_control==0.5
replace anti_econ_control=0 if econ_control==1
tab anti_econ_control econ_control, m

gen anti_state_employment=.
replace anti_state_employment=0.3333333 if state_employment>0.5 & state_employment<1
replace anti_state_employment=0.6666666 if state_employment>0 & state_employment<0.5
replace anti_state_employment=1 if state_employment==0
replace anti_state_employment=0.5 if state_employment==0.5
replace anti_state_employment=0 if state_employment==1
tab anti_state_employment state_employment, m

gen index_interest=( gpi+ talk_politic +newspaper_politics )/3
global keepers1973 $keepers1973 index_interest

gen index_market_oriented=(socref + anti_state_employment +no_state+ anti_econ_control +right )/5
global keepers1973 $keepers1973 index_market_oriented
